package org.theSeed.web.sysEnum;

import cn.hutool.core.util.ObjectUtil;
import lombok.Getter;

/**
 * 过滤器顺序
 */
public enum FilterOrder {
    TRACE(Integer.MIN_VALUE,"链路"),
    REPEAT_READ(Integer.MIN_VALUE + 20000,"可重复读写"),
    REQUEST_LOG(Integer.MIN_VALUE + 21000,"请求日志"),
    ;
    FilterOrder(Integer code, String describStr) {
        this.code = code;
        this.describStr = describStr;
    }

    /**
     * 编码
     */
    @Getter
    private Integer code;

    /**
     * 描述字符
     */
    @Getter
    private String describStr;

    /**
     * 获取实例
     * @param code
     * @return
     */
    public static FilterOrder getInstance(Integer code){
        if (ObjectUtil.isNull(code)){
            return null;
        }

        for (FilterOrder item : values()) {
            if (item.code.equals(code))
                return item;
        }
        return null;
    }
}
